package com.wawei.seeds.services;

import android.content.Context;
import android.os.Handler;

import com.wawei.seeds.adapter.ChampionAchievementFragmentAdapter;
import com.wawei.seeds.champion.ChampionAchievementTabFragment;
import com.wawei.seeds.utils.RetrofitNetworkService;

import java.util.ArrayList;
import java.util.List;

import retrofit.RestAdapter;

/**
 * Created by parker on 15/6/14.
 */
public class AchievementServiceHandler {
    private Context context;

    public AchievementServiceHandler(Context context) {
        this.context = context;
    }

    public void retriveAchievement(RestAdapter restAdapter, int count,
                               final Handler handler, final Integer handlerTag){
        List<ChampionAchievementFragmentAdapter.ChampionAchievementItem> items = new ArrayList<>(0);
        ChampionAchievementFragmentAdapter.ChampionAchievementItem item;
        switch (handlerTag.intValue()){
            case ChampionAchievementTabFragment.LOAD_NEW_ACHIEVE_DATA:
                for(int i=0;i<10;i++) {
                    item = new ChampionAchievementFragmentAdapter.ChampionAchievementItem();
                    item.achievementTitle = new String("APP" + Math.rint(10 * Math.random()) + "原型设计");
                    item.achievementPublishTime = new String("15-06-03 13:20:34_" + Math.rint(100 * Math.random()));
                    item.achievementWorkers = "Works: " + Math.rint(10 * Math.random());

                    items.add(item);
                }//End of mock
                break;
            case ChampionAchievementTabFragment.LOAD_OLD_ACHIEVE_DATA:
                for(int i=0;i<10;i++) {
                    item = new ChampionAchievementFragmentAdapter.ChampionAchievementItem();
                    item.achievementTitle = new String("APP" + Math.rint(10 * Math.random()) + "原型设计");
                    item.achievementPublishTime = new String("15-06-03 13:20:34_" + Math.rint(100 * Math.random()));
                    item.achievementWorkers = "Works: " + Math.rint(10 * Math.random());

                    items.add(item);
                }//End of mock
                break;
            case ChampionAchievementTabFragment.INIT_ACHIEVE_DATA:
                for(int i=0;i<20;i++){
                    item = new ChampionAchievementFragmentAdapter.ChampionAchievementItem();
                    item.achievementTitle = "手机打卡测试" + i;
                    item.achievementPublishTime = "15-05-11_" + i;
                    item.achievementWorkers = "Works: " + (i + 1);
                    items.add(item);
                }
                break;
            default:
                break;
        }
        RetrofitNetworkService.handleSuccess(handler, handlerTag, items.toArray());
    }
}
